<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2017/6/5
 * Time: 上午11:31
 */

$method = $_SERVER['REQUEST_METHOD'];

if ($method === "POST") {
    $name = $_POST['name'];
    $age = $_POST['age'];
    if ($name === 'zing') {
        echo json_encode([
            'status' => true,
            'person' => [
                'name' => $name,
                'age' => $age
            ],
            'result' => '登录成功',
            'type' => 'Success',
        ]);
    } else {
        echo json_encode([
            'status' => false,
            'result' => 'the name is wrong !!!',
            'type' => 'Warning',
        ]);
    }
} elseif ($method === "GET") {
    echo "GET";
} else {
    echo "other";
}
